<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="utf-8" />
		<title>Bootstrap表格插件 - Bootstrap后台管理系统模版Ace下载</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<!-- basic styles -->

		<link href="css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/font-awesome.min.css" />

		<!--[if IE 7]>
		  <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->

		<!-- fonts -->

		<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" />

		<!-- ace styles -->

		<link rel="stylesheet" href="css/ace.min.css" />
		<link rel="stylesheet" href=css/ace-rtl.min.css" />
		<link rel="stylesheet" href="css/ace-skins.min.css" />

		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->

		<script src="js/ace-extra.min.js"></script>

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="assets/js/html5shiv.js"></script>
		<script src="assets/js/respond.min.js"></script>
		<![endif]-->
<style type="text/css">
input[name=theType]{
	margin-left:20px;
	margin-right:5px;
}
.navbar{
	background-color:#8192D6 !important;
	height:55px;
	line-height:55px !important;
}
.table-header{
	background-color:#D9B3E6;
	font-size:16px;
	height:48px;
	text-align:center !important;
	line-height:48px;
	border-radius:10px 10px 0 0;
}	
.admin{
	text-shadow: 5px 2px 3px #a49f9f;
}	
.breadcrumb{
	margin: 10px 22px 10px 12px;
}
</style>
	</head>

	<body>
		<div class="navbar navbar-default" id="navbar">
			<script type="text/javascript">
				try{ace.settings.check('navbar' , 'fixed')}catch(e){}
			</script>

			<div class="navbar-container" id="navbar-container">
				<div class="navbar-header pull-left">
					<a href="#" class="navbar-brand">
						<small class="admin">
							<i class="icon-leaf"></i>
							Super Admin
						</small>
					</a><!-- /.brand -->
				</div><!-- /.navbar-header -->

			</div><!-- /.container -->
		</div>

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>

				<div class="sidebar" id="sidebar">
					<script type="text/javascript">
						try{ace.settings.check('sidebar' , 'fixed')}catch(e){}
					</script>

					<div class="sidebar-shortcuts" id="sidebar-shortcuts">
						<div class="sidebar-shortcuts-large" id="sidebar-shortcuts-large">
							<button class="btn btn-success">
								<i class="icon-signal"></i>
							</button>

							<button class="btn btn-info">
								<i class="icon-pencil"></i>
							</button>

							<button class="btn btn-warning">
								<i class="icon-group"></i>
							</button>

							<button class="btn btn-danger">
								<i class="icon-cogs"></i>
							</button>
						</div>

						<div class="sidebar-shortcuts-mini" id="sidebar-shortcuts-mini">
							<span class="btn btn-success"></span>

							<span class="btn btn-info"></span>

							<span class="btn btn-warning"></span>

							<span class="btn btn-danger"></span>
						</div>
					</div><!-- #sidebar-shortcuts -->
<ul class="nav nav-list">
						<li class="active">
							<a href="index.html">
								<i class="icon-dashboard"></i>
								<span class="menu-text"> 控制台 </span>
							</a>
						</li>

						<li>
							<a href="index.jsp">
								<i class="icon-calendar"></i>

								<span class="menu-text">
									日历
								</span>
							</a>
						</li>

						<li>
							<a href="gallery.html">
								<i class="icon-picture"></i>
								<span class="menu-text"> 相册 </span>
							</a>
						</li>

						<li>
							<a href="#" class="dropdown-toggle">
								<i class="icon-tag"></i>
								<span class="menu-text"> 更多页面 </span>

								<b class="arrow icon-angle-down"></b>
							</a>

							<ul class="submenu">
								<li>
									<a href="profile.html">
										<i class="icon-double-angle-right"></i>
										用户信息
									</a>
								</li>
								<li>
									<a href="login.html">
										<i class="icon-double-angle-right"></i>
										登录 &amp; 注册
									</a>
								</li>
							</ul>
						</li>
						<li>
							<a href="#" class="dropdown-toggle">
								<i class="icon-file-alt"></i>

								<span class="menu-text">
									其他页面
									<!-- <span class="badge badge-primary ">3</span> -->
								</span>

								<b class="arrow icon-angle-down"></b>
							</a>

							<ul class="submenu">
								<li>
									<a href="faq.html">
										<i class="icon-double-angle-right"></i>
										帮助
									</a>
								</li>

								<li>
									<a href="error-404.html">
										<i class="icon-double-angle-right"></i>
										404错误页面
									</a>
								</li>

								<li>
									<a href="error-500.html">
										<i class="icon-double-angle-right"></i>
										500错误页面
									</a>
								</li>
							</ul>
						</li>
					</ul><!-- /.nav-list -->
					<div class="sidebar-collapse" id="sidebar-collapse">
						<i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
					</div>

					<script type="text/javascript">
						try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
					</script>
				</div>

				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								<a href="index.jsp">首页</a>
							</li>
							<li class="active">Tables</li>
						</ul><!-- .breadcrumb -->

					<div class="page-content">

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->

								<div class="row">
									<div class="col-xs-12">
										<h3 class="header smaller lighter blue">所有事件列表</h3>
										<div class="table-header">
											You can change the type of the events there.
										</div>

										<div class="table-responsive">
											<table id="sample-table-2" class="table table-striped table-bordered table-hover">
												<thead>
													<tr>
														<th class="center">
															<label>
																<input type="checkbox" class="ace" />
																<span class="lbl"></span>
															</label>
														</th>
														<th>事件</th>				
														<th>开始时间</th>
														<th>结束时间</th>
														
														<th class="hidden-480">状态</th>

														<th>操作</th>
													</tr>
												</thead>

												<tbody id="myForm">
												</tbody>
											</table>
										</div>
									</div>
								</div>

								<!-- modal -->
						<div class="modal fade" id="myModoal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
									  <div class="modal-dialog" role="document">
									    <div class="modal-content">
									      <div class="modal-header">
									        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
									        <h4 class="modal-title" id="exampleModalLabel">修改事件</h4>
									      </div>
									      <div class="modal-body">
									        <form>
									          <div class="form-group">
									            <label for="recipient-name" class="control-label">事件内容：</label>
									            <textarea class="form-control" id="message-text"></textarea>
									          </div>
									         <div class="form-group">
									            <label for="recipient-name" class="control-label">开始时间:</label>
									            <input type="text" class="form-control" id="startTime">
          									 </div>
          									  <div class="form-group">
									            <label for="recipient-name" class="control-label">结束时间:</label>
									            <input type="text" class="form-control" id="endTime">
          									 </div>
									          <div class="form-group">
									            <label for="message-text" class="control-label">事件类型:</label><br>
									           <input type="radio" id="a_label-info" checked value="label-info" name="theType"/><span class="label label-sm label-info">计划中</span>
									           <input type="radio" id="a_label-warning" value="label-yellow" name="theType"/><span class="label label-sm label-warning">进行中</span>
									           <input type="radio" id="a_label-danger" value="label-danger" name="theType"/><span class="label label-sm label-danger">未完成</span>
									           <input type="radio" id="a_label-success" value="label-success" name="theType"/><span class="label label-sm label-success">已完成</span>
									          </div>
									        </form>
									      </div>
									      <div class="modal-footer">
									        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
									        <button type="button" class="btn btn-primary" id="sureChange">确认</button>
									      </div>
									    </div>
									  </div>
									</div>
								<!-- modal -->
								<!-- modal2 -->
						<div class="modal fade" id="myModoal2" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
									  <div class="modal-dialog" role="document">
									    <div class="modal-content">
									      <div class="modal-header">
									        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
									        <h4 class="modal-title" id="exampleModalLabel">修改事件</h4>
									      </div>
									      <div class="modal-body">
									        <form>
									          <div class="form-group">
									            <label for="recipient-name" class="control-label">事件内容：</label>
									            <textarea class="form-control" id="message-text"></textarea>
									          </div>
									         <div class="form-group">
									            <label for="recipient-name" class="control-label">开始时间:</label>
									            <input type="text" class="form-control" id="startTime">
          									 </div>
          									  <div class="form-group">
									            <label for="recipient-name" class="control-label">结束时间:</label>
									            <input type="text" class="form-control" id="endTime">
          									 </div>
									          <div class="form-group">
									            <label for="message-text" class="control-label">事件类型:</label><br>
									           <input type="radio" checked value="label-info" name="theType"/><span class="label label-sm label-info">计划中</span>
									           <input type="radio" value="label-yellow" name="theType"/><span class="label label-sm label-warning">进行中</span>
									           <input type="radio" value="label-danger" name="theType"/><span class="label label-sm label-danger">未完成</span>
									           <input type="radio" value="label-success" name="theType"/><span class="label label-sm label-success">已完成</span>
									          </div>
									        </form>
									      </div>
									      <div class="modal-footer">
									        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
									        <button type="button" class="btn btn-primary" id="sureChange">确认</button>
									      </div>
									    </div>
									  </div>
									</div>
								<!-- modal2 -->
								
								</div><!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->

				<div class="ace-settings-container" id="ace-settings-container">
					<div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
						<i class="icon-cog bigger-150"></i>
					</div>

					 <div class="ace-settings-box" id="ace-settings-box">
						<div>
							<div class="pull-left">
								<select id="skin-colorpicker" class="hide">
									<option data-skin="default" value="#438EB9">#438EB9</option>
									<option data-skin="skin-1" value="#222A2D">#222A2D</option>
									<option data-skin="skin-2" value="#C6487E">#C6487E</option>
									<option data-skin="skin-3" value="#D0D0D0">#D0D0D0</option>
								</select>
							</div>
							<span>&nbsp; 更改主题颜色</span>
						</div> 

						<div>
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-navbar" />
							<label class="lbl" for="ace-settings-navbar"> Fixed Navbar</label>
						</div>
						<div>
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-sidebar" />
							<label class="lbl" for="ace-settings-sidebar"> Fixed Sidebar</label>
						</div>
						<div>
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-breadcrumbs" />
							<label class="lbl" for="ace-settings-breadcrumbs"> Fixed Breadcrumbs</label>
						</div>
						<div>
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-rtl" />
							<label class="lbl" for="ace-settings-rtl"> Right To Left (rtl)</label>
						</div>
						<div>
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container" />
							<label class="lbl" for="ace-settings-add-container">
								Inside
								<b>.container</b>
							</label>
						</div>
					</div>
				</div><!-- /#ace-settings-container -->
			</div><!-- /.main-container-inner -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!-- basic scripts -->

		<!--[if !IE]> -->

		<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

		<!-- <![endif]-->

		<!--[if IE]>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<![endif]-->

		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="js/bootstrap.min.js"></script>
		<script src="js/typeahead-bs2.min.js"></script>

		<!-- page specific plugin scripts -->

		<script src="js/jquery.dataTables.min.js"></script>
		<script src="js/jquery.dataTables.bootstrap.js"></script>

		<!-- ace scripts -->

		<script src="js/ace-elements.min.js"></script>
		<script src="js/ace.min.js"></script>

		<!-- inline scripts related to this page -->

		<script type="text/javascript">
		$(document).ready(function(){
			$.ajax({
				url:"queryEvent",
				type:"get",
			  	dataType:"json", 
			success:function(data){
			   // var objt = JSON.stringify(data); 
				var str = ''; 
				for(var i=0;i<data.length;i++){
					var listName = data[i].title;
					var type = data[i].className;
					var start = data[i].start;
					var end = data[i].end;
					var Id = data[i].id;  
					var typeName;
					 if(type=="label-yellow"){
						 type = "label-warning";
						 typeName = "进行中";
					}else if(type=="label-success"){
						 typeName = "已完成";
					}else if(type=="label-info"){
						 typeName = "计划中";
					}else if(type=="label-danger"){
						 typeName = "未完成";
					}
					 
					str +='<tr name="'+Id+'"><td class="center"><label><input type="checkbox" class="ace" /><span class="lbl"></span></label></td><td class="myTitle">'+data[i].title+'</td><td class="myStart">'+start+'</td><td class="myEnd">'+end+'</td><td class="hidden-480"><span name="'+type+'" class="myClass label label-sm '+type+'">'+typeName+'</span></td><td><div class="visible-md visible-lg hidden-sm hidden-xs action-buttons"><a class="blue"><i class="icon-zoom-in bigger-130"></i></a><a class="green  changeEvent"><i data-toggle="modal" data-target="#myModoal" class="icon-pencil bigger-130"></i></a><a class="red delete"><i class="icon-trash bigger-130"></i></a></div><div class="visible-xs visible-sm hidden-md hidden-lg"><div class="inline position-relative"><button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown"><i class="icon-caret-down icon-only bigger-120"></i></button>'+
						'<ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close"><li><a class="tooltip-info" data-rel="tooltip" title="View"><span class="blue"><i class="icon-zoom-in bigger-120"></i></span></a></li>'+
						'<li><a href="#" class="tooltip-success" data-rel="tooltip" title="Edit"><span class="green"><i class="icon-edit bigger-120"></i></span></a></li>'+
						'<li class="delete"><a class="tooltip-error" data-rel="tooltip" title="Delete"><span class="red"><i class="icon-trash bigger-120"></i></span></a></li>'+
						'</ul></div></div></td></tr>';
					//alert(type);
				}
				$("#myForm").append(str);
		},
		 error: function(XMLHttpRequest, textStatus, errorThrown) {
			 alert(XMLHttpRequest.status);
			 alert(XMLHttpRequest.readyState);
			 alert(textStatus);
		 }
	})  //ajax结束
})//document
			jQuery(function($) {
				var oTable1 = $('#sample-table-2').dataTable({
				"aoColumns": [
			      { "bSortable": false },
			      null, null,null, null, null,
				  { "bSortable": false }
				] } );
				
				
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
						
				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
			})

	 	$(document).on('click', '.delete',function() { 
	 		var title = $(this).parents("tr").find(".myTitle").html();
    		var start = $(this).parents("tr").find(".myStart").html();
    		if(confirm("确认删除该计划吗？")){
    			jQuery.post("deleteEvent",{"title":title,"start":start},function(){
    				alert("删除成功！");
    				window.location.reload();
    			});	
    		}
    		
		});
		$(document).on('click', '.changeEvent',function() { 
			var Id = parseInt($(this).parents("tr").attr("name"));
    		var oldName = $(this).parents("tr").find(".myTitle").html();
    		var startTime = $(this).parents("tr").find(".myStart").html();
    		var endTime = $(this).parents("tr").find(".myEnd").html();
    		var firstClass = $(this).parents("tr").find(".myClass").attr("name");

    		$('#a_'+firstClass).attr("checked","checked");
    		$("#message-text").val(oldName);
    		$("#startTime").val(startTime);
    		$("#endTime").val(endTime);
    		$("#sureChange").bind('click',function(){
    			var title = $("#message-text").val();
    			var className = $('input[name="theType"]:checked').val();
    			var start = $("#startTime").val();
    			var end = $("#endTime").val();
    			 $.ajax({
    				url:"updateType",
    				type:"post",
    				data:{"Id":Id,"title":title,"start":start,"end":end,"className":className},
    				success:function(){
    					window.location.reload();
    				}
    			}) 
    		})
    		//alert(oldName);
		});
		</script>
	<div style="display:none"><script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script></div>
</body>
</html>
